package top.minuy.algorithm.sort.merge;

import top.minuy.util.constant.SortType;
import top.minuy.util.generate.ArrayGenerator;
import top.minuy.util.helper.SortingHelper;
/**
 * @author Minuy
 * @time 10:36
 * @date 2021/8/28
 */
public class Test {
    public static void main(String[] args) {
        Integer[] data = {2,3,1,12,2,9,1};
        MergeSort.sort(data);
        System.out.println("结果：");
        for (int i:data             ) {
            System.out.print(i+" ");
        }
        System.out.println();
        Integer[] data1 = {2,3,1,12,2,9,1};
        System.out.println("自底向上：");
        MergeBuSort.sort(data1);
        System.out.println("结果：");
        for (int i:data1) {
            System.out.print(i+" ");
        }

        System.out.println("性能测试：");

        int[] dataSize = {10000, 10000};

        for (int n : dataSize) {

            System.out.println("---------DataSize = "+n);

            Integer[] arr1 = ArrayGenerator.generateRandomArray(n, n);

            Integer[] arr2 = new Integer[arr1.length];
            System.arraycopy(arr1, 0, arr2, 0, arr1.length);

            Integer[] arr3 = new Integer[arr1.length];
            System.arraycopy(arr1, 0, arr3, 0, arr1.length);

            Integer[] arr4 = new Integer[arr1.length];
            System.arraycopy(arr1, 0, arr4, 0, arr1.length);

            SortingHelper.SortTest(SortType.MergeSort, arr2);
            SortingHelper.SortTest(SortType.MergeBuSort, arr4);
            SortingHelper.SortTest(SortType.InsertionSort, arr1);
            SortingHelper.SortTest(SortType.SelectSort, arr3);
        }

    }
}
